package org.gap.service;

import java.util.List;
import java.util.Set;

import org.gap.domain.EtablissementsBancaires;
import org.gap.domain.Guichets;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class GuichetsServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected GuichetsService service;

	/**
	 * Instantiates a new GuichetsServiceTest.
	 *
	 */
	public GuichetsServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing EtablissementsBancaires entity
	 * 
	 */
	@Test
	public void deleteGuichetsEtablissementsBancaires() {
		// TODO: JUnit - Populate test inputs for operation: deleteGuichetsEtablissementsBancaires 
		Integer guichets_guiEtablissement = 0;
		Integer guichets_guiGuichet = 0;
		String guichets_guiPays = null;
		String related_etablissementsbancaires_etbPays = null;
		Integer related_etablissementsbancaires_etbEtablissement = 0;
		Guichets response = null;
		response = service.deleteGuichetsEtablissementsBancaires(guichets_guiEtablissement, guichets_guiGuichet, guichets_guiPays, related_etablissementsbancaires_etbPays, related_etablissementsbancaires_etbEtablissement);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteGuichetsEtablissementsBancaires
	}

	/**
	 * Operation Unit Test
	 * Save an existing Guichets entity
	 * 
	 */
	@Test
	public void saveGuichets() {
		// TODO: JUnit - Populate test inputs for operation: saveGuichets 
		Guichets guichets = new org.gap.domain.Guichets();
		service.saveGuichets(guichets);
	}

	/**
	 * Operation Unit Test
	 * Return all Guichets entity
	 * 
	 */
	@Test
	public void findAllGuichetss() {
		// TODO: JUnit - Populate test inputs for operation: findAllGuichetss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Guichets> response = null;
		response = service.findAllGuichetss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllGuichetss
	}

	/**
	 * Operation Unit Test
	 * Load an existing Guichets entity
	 * 
	 */
	@Test
	public void loadGuichetss() {
		Set<Guichets> response = null;
		response = service.loadGuichetss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadGuichetss
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findGuichetsByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findGuichetsByPrimaryKey 
		Integer guiEtablissement = 0;
		Integer guiGuichet = 0;
		String guiPays = null;
		Guichets response = null;
		response = service.findGuichetsByPrimaryKey(guiEtablissement, guiGuichet, guiPays);
		// TODO: JUnit - Add assertions to test outputs of operation: findGuichetsByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Guichets entity
	 * 
	 */
	@Test
	public void deleteGuichets() {
		// TODO: JUnit - Populate test inputs for operation: deleteGuichets 
		Guichets guichets_1 = new org.gap.domain.Guichets();
		service.deleteGuichets(guichets_1);
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Guichets entity
	 * 
	 */
	@Test
	public void countGuichetss() {
		Integer response = null;
		response = service.countGuichetss();
		// TODO: JUnit - Add assertions to test outputs of operation: countGuichetss
	}

	/**
	 * Operation Unit Test
	 * Save an existing EtablissementsBancaires entity
	 * 
	 */
	@Test
	public void saveGuichetsEtablissementsBancaires() {
		// TODO: JUnit - Populate test inputs for operation: saveGuichetsEtablissementsBancaires 
		Integer guiEtablissement_1 = 0;
		Integer guiGuichet_1 = 0;
		String guiPays_1 = null;
		EtablissementsBancaires related_etablissementsbancaires = new org.gap.domain.EtablissementsBancaires();
		Guichets response = null;
		response = service.saveGuichetsEtablissementsBancaires(guiEtablissement_1, guiGuichet_1, guiPays_1, related_etablissementsbancaires);
		// TODO: JUnit - Add assertions to test outputs of operation: saveGuichetsEtablissementsBancaires
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
